﻿@using Microsoft.AspNetCore.Mvc.Localization
@using Skoruba.IdentityServer4.Admin.BusinessLogic.Shared.Dtos.Common
@using Skoruba.IdentityServer4.Admin.Helpers
@model Skoruba.IdentityServer4.Admin.BusinessLogic.Dtos.Log.LogsDto
@inject IViewLocalizer Localizer

@{
	ViewBag.Title = Localizer["PageTitle"];
	Layout = "_Layout";
}

<h2>@Localizer["PageTitle"]</h2>

<div class="row">
	<div class="col-12">
		@await Html.PartialAsync("Common/Search", new Search { Action = "ErrorsLog", Controller = "Log" })
	</div>
</div>

<div class="row">
	<div class="col-12">
		<div class="table-responsive">
			<table class="table table-striped">
				<thead>
					<tr>
						<th></th>
						<th>@Localizer["TableLevel"]</th>
						<th>@Localizer["TableLogged"]</th>
						<th>@Localizer["TableMessage"]</th>
					</tr>
				</thead>
				<tbody>
					@foreach (var client in Model.Logs)
					{
						<tr>
							<td><a href="#" data-error-id="@client.Id" class="btn btn-primary btn-error-detail">@Localizer["TableShowDetail"]</a></td>
							<td>@client.Level</td>
							<td>
								<span class="local-datetime" title="@client.TimeStamp" data-utc="@client.TimeStamp.GetEpochTicks()" data-toggle="tooltip" data-placement="top">
									@client.TimeStamp
								</span>								
								<span class="oi oi-clock" title="@client.TimeStamp" data-toggle="tooltip" data-placement="top"></span>
							</td>
							<td>@client.Message</td>
						</tr>
						<tr class="row-error-detail d-none" data-error-id="@client.Id">
							<td colspan="4" data-error-json="@client.LogEvent"></td>
						</tr>
					}
				</tbody>
			</table>
		</div>
	</div>
</div>

<div class="row">
	<div class="col-12">
		@await Html.PartialAsync("Common/Pager", new Pager { Action = "ErrorsLog", PageSize = Model.PageSize, TotalCount = Model.TotalCount, EnableSearch = true, Search = ViewBag.Search })
	</div>
</div>